package regexppractice;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @description:
 * @author: jhy
 * @time: 2021/6/1 14:48
 */

//匹配url
public class RegExpDemo5 {

    public static void main(String[] args) {

        String content = "https://www.bilibili.com/video/BV1fh411y7R8?from=search&seid=1831060912083761326";

        String regStr = "^((http|https)://)?([\\w-]+\\.)+[\\w-]+(\\/[\\w-?=&/%.#]*)?$";

        Pattern pattern = Pattern.compile(regStr);

        Matcher matcher = pattern.matcher(content);
        if (matcher.find()){
            System.out.println("匹配成功");
        }else {
            System.out.println("匹配失败");
        }
    }
}
